package com.hutao.manage.query;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hutao.manage.util.StringUtil;

/**
 * 归档查询类
 * @author lyh
 *
 */
public class MedBindQuery extends PageQuery {

	private String name;
	
	private String idCard;
	
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date uploadStartDate;
	
	
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date uploadEndDate;
	
	private Integer bindStatus = 0;
	
	/**
	 * 是否关联
	 */
	private Integer relevanceStatus;
	
	/**
	 * 是否编页
	 */
	private Integer paginationStatus;
	
	private Integer outHospitalOfficeId;
	
	private String mrId;
	
	private String userCode;

	private Object datas;
	
	public String getUserCode() {
		return StringUtil.meaningStr(userCode);
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public String getName() {
		
		return StringUtil.meaningStr(name);
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIdCard() {
		return StringUtil.meaningStr(idCard);
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public Date getUploadStartDate() {
		return uploadStartDate;
	}

	public void setUploadStartDate(Date uploadStartDate) {
		this.uploadStartDate = uploadStartDate;
	}

	public Date getUploadEndDate() {
		return uploadEndDate;
	}

	public void setUploadEndDate(Date uploadEndDate) {
		this.uploadEndDate = uploadEndDate;
	}

	public Integer getBindStatus() {
		return bindStatus;
	}

	public void setBindStatus(Integer bindStatus) {
		this.bindStatus = bindStatus;
	}

	public Integer getOutHospitalOfficeId() {
		return outHospitalOfficeId;
	}

	public void setOutHospitalOfficeId(Integer outHospitalOfficeId) {
		this.outHospitalOfficeId = outHospitalOfficeId;
	}

	public String getMrId() {
		return StringUtil.meaningStr(mrId);
	}

	public void setMrId(String mrId) {
		this.mrId = mrId;
	}

	public String getOnlyId() {
		if(this.getMrId() != null){
			return this.getMrId() +"-%";
		}
		return null;
	}
	
	public Integer getRelevanceStatus() {
		return relevanceStatus;
	}

	public void setRelevanceStatus(Integer relevanceStatus) {
		this.relevanceStatus = relevanceStatus;
	}

	public Integer getPaginationStatus() {
		return paginationStatus;
	}

	public void setPaginationStatus(Integer paginationStatus) {
		this.paginationStatus = paginationStatus;
	}

	
	
	public Object getDatas() {
		return datas;
	}

	public void setDatas(Object datas) {
		this.datas = datas;
	}

	public boolean isQuery(){
		dealDate();
		if(StringUtil.meaningStr(name) == null && StringUtil.meaningStr(idCard)==null && uploadStartDate==null 
				&& uploadEndDate==null && bindStatus==null){
			return false;
		}
		return true;
	}
	
	@JsonIgnore
	public boolean isEmpty(){
		dealDate();
		if(this.getUploadStartDate()==null && this.getUploadEndDate()==null && this.getMrId()==null){
			return true;
		}
		return false;
	}

	private void dealDate() {
		if (this.getUploadStartDate() == null && this.getUploadEndDate() != null) {
			this.setUploadStartDate(this.getUploadEndDate());
		} else if (this.getUploadStartDate() != null && this.getUploadEndDate() == null) {
			this.setUploadEndDate(this.getUploadStartDate());
		}

	}
}
